package com.example.JavaDemo.Controller;

/**
 * 接口文档访问地址 http://127.0.0.1:8089/swagger-ui/index.html
 * apifox 导入接口数据 http://127.0.0.1:8089/v2/api-docs
 */
import com.example.JavaDemo.domain.Community;
import com.example.JavaDemo.domain.Resident;
import com.example.JavaDemo.service.IResidentService;
import com.example.comon.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/resident")
@Api(value = "resident",tags = "住户管理")
public class ResidentController {
    @Autowired
    private IResidentService residentService;

    @GetMapping("/getResidentList")
    @ApiOperation("获取用户列表")
    public R<List<Resident>> getResidentList(Resident resident){
        List<Resident> list = residentService.selectResident(resident);
        return R.success(list);    }

    @PostMapping("/addResident")
    @ApiOperation("增加住户")
    public R<Resident> addResident(@RequestBody Resident resident){
        residentService.insertResident(resident);
        return R.success(resident);
    }

    @PostMapping("/updateResidentById")
    @ApiOperation("修改用户")
    public R<List<Community>> updateResidentById(@RequestBody Resident resident){
        residentService.updateResidentById(resident);
        return R.success();
    }

    @DeleteMapping("/delResidentById")
    @ApiOperation("删除住户")
    public R<List<Community>> delResidentById(String residentId){
        residentService.delResidentById(residentId);
        return R.success();
    }
}
